﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TarreOA.TarreOAModels;
using TarreOA.TarreOABLL;

public partial class admin_FindBlurSupply : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["user"] == null)
        {
            Session["ShowMessage"] = "用户未登录，请重新登录!";
            Session["Backurl"] = "Login.aspx";
            Response.Redirect("~/Main.aspx");
        }
        else
        {
            TarreOA.TarreOAModels.User sucessUser = (User)Session["user"];
            bool userFlag = false;
            if (sucessUser.PopedomGroup.PopedomList != null)
            {
                foreach (Popedom var in sucessUser.PopedomGroup.PopedomList)
                {
                    if (var.PopedomId == 44)
                    {
                        userFlag = true;
                        break;
                    }
                }
            }
            if (!userFlag)
            {
                Session["ShowMessage"] = "用户没有该权限，请与管理员联系!";
                Session["Backurl"] = "Right.aspx";
                Response.Redirect("~/Message.aspx");
            }
        }
        if (!IsPostBack)
        {
            TarreOA.TarreOAModels.User user = (User)Session["user"];
            Label2.Text = "新建供应商（供应商总数 " + SupplyManager.CountAllSupply(user.UserId).ToString() + " ）";
        }
    }
    protected void Button3_Click(object sender, ImageClickEventArgs e)
    {
        Supply supply = new Supply();
        if (txtSupplyName.Text !=null && txtSupplyName.Text != "")
        {
            supply.SupplyName = txtSupplyName.Text;
        }
        if (txtTelephone.Text !=null && txtTelephone.Text !="")
        {
            supply.Telephone = txtTelephone.Text;
        }
        if (txtFaxes.Text !=null && txtFaxes.Text !="")
        {
            supply.Faxes = txtFaxes.Text;
        }
        if (txtURL.Text != null && txtURL.Text !="")
        {
            supply.Url = txtURL.Text;
        }
        if (txtEmail.Text !=null&& txtEmail.Text!="")
        {
            supply.Email = txtEmail.Text;
        }
        if (txtAddress.Text != null && txtAddress.Text !="")
        {
            supply.Address = txtAddress.Text;
        }
        if (txtPostalcode.Text !=null && txtPostalcode.Text !="")
        {
            supply.Postalcode = txtPostalcode.Text;
        }
        if (txtRemark.Text !=null && txtRemark.Text !="")
        {
            supply.Remark = txtRemark.Text;
        }
        if (txtBankAccounts.Text !=null && txtBankAccounts.Text !="")
        {
            supply.BankAccounts = txtBankAccounts.Text;
        }
        if (txtAccounts.Text != null && txtAccounts.Text !="")
        {
            supply.Accounts = txtAccounts.Text;
        }
        Session["Supply"] = supply;
        Response.Redirect("SupplyList.aspx");
    }
}
